package com.huatai.datadevelop.controller;

import com.huatai.common.api.R;
import com.huatai.datadevelop.entity.SysDocEntity;
import com.huatai.datadevelop.service.DocService;
import com.huatai.datadevelop.vo.DeleteVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author zhangbenting
 * @Description TODO
 * @Date 2023/9/19 18:37
 * @Version 1.0
 */
@RestController
@RequestMapping("/sys/doc")
public class SysDocController {

	@Autowired
	private DocService docService;

	/**
	 * 获取列表
	 */
	@PostMapping("/list")
	public R list(@RequestBody Map<String, Object> params){
		return R.data(docService.queryPage(params));
	}

	/**
	 * 新增或更新
	 * docId不存在或小于等于0时   即为新增
	 * @param sysDocEntity
	 * @return
	 */
	@PostMapping("/save")
	public R addDoc(@RequestBody SysDocEntity sysDocEntity){
		return R.data(this.docService.saveOrUpdateEntity(sysDocEntity));
	}

	/**
	 * 删除文档
	 * @param data
	 * @return
	 */
	@PostMapping("/delete")
	public R delete(@RequestBody DeleteVO data){
		return R.data(this.docService.removeByIds(data.getIds()));
	}
}
